package com.jkl.controller.home;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.home.HomeRequestEntity;
import com.jkl.entity.home.SourceResponseEnetity;
import com.jkl.service.home.sourceCassificationInter.SourceCassificationNewService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zjj
 * @date  2019/9/2 14:59
 * @Description  ${描述一个类的相关信息}
 */
@RestController
@RequestMapping("/jky/home/source")
@Slf4j
public class SourceClassificationController {
//    @Autowired
//   SourceCassificationService sourceCassificationService;
    @Autowired
    SourceCassificationNewService sourceCassificationService;

    /**
     *覆盖率变化趋势
     */
    @PostMapping("/coverageChange")
    public BaseResponseDTO getCoverageTrend(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        SourceResponseEnetity coverageTrend = sourceCassificationService.getCoverageTrend( homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(coverageTrend));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     *覆盖情况
     */
    @PostMapping("/coverageDetain")
    public BaseResponseDTO getCoverageSituation(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        SourceResponseEnetity coverageSituation = sourceCassificationService.getCoverageSituation(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(coverageSituation));
        returnData.setReturnData(jsonObject);
        return returnData;
    }









    /**
     *区域综合覆盖排行
     */
    @PostMapping("/areaCoverageRanking")
    public BaseResponseDTO getAreaCoverageRanking(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        List<SourceResponseEnetity> areaCoverageRanking = sourceCassificationService.getAreaCoverageRanking(homeRequestEntity);
        JSONObject returnJson = new JSONObject();
        JSONArray areaCoverageRankingArray = (JSONArray) JSONArray.toJSON(areaCoverageRanking);
        returnJson.put("areaCoverageRankingList",areaCoverageRankingArray);
        returnData.setReturnData(returnJson);
        return returnData;
    }
    /**
     *示范建设情况
     */
    @PostMapping("/buildingProgress")
    public BaseResponseDTO getHarmLesscircleAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        SourceResponseEnetity buildingProgress = sourceCassificationService.getBuildingProgress(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(buildingProgress));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     *定时定点示范点
     */
    @PostMapping("/timedDemonstration")
    public BaseResponseDTO getTimedDemonstration(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        Map<String, Object> timedDemonstration = sourceCassificationService.getTimedDemonstration(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(timedDemonstration));
        returnData.setReturnData(jsonObject);
        return returnData;
    }
    /**
     *示范点建设完成情况综合排行
     */
    @PostMapping("/demonstrationPointBuildDetain")
    public BaseResponseDTO getDemonstrationPointBuildDetain(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        List<SourceResponseEnetity> demonstrationPointBuildDetain = sourceCassificationService.getDemonstrationPointBuildDetain(homeRequestEntity);
        JSONObject returnJson = new JSONObject();
        JSONArray demonstrationPointBuildDetainArray = (JSONArray) JSONArray.toJSON(demonstrationPointBuildDetain);
        returnJson.put("demonstrationPointBuildDetainList", demonstrationPointBuildDetainArray);
        returnData.setReturnData(returnJson);
        return returnData;
    }

    /**
     * gis展示
     */
    @PostMapping("/gis")
    public BaseResponseDTO getGisAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        SourceResponseEnetity gisAnalysis = sourceCassificationService.getGisAnalysis(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(gisAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     * 开展情况对比展示
     */
    @PostMapping("/contrast")
    public BaseResponseDTO getContrastAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        List<SourceResponseEnetity> demonstrationPointBuildDetain = sourceCassificationService.getContrastAnalysis(homeRequestEntity);
        JSONObject returnJson = new JSONObject();
        JSONArray demonstrationPointBuildDetainArray = (JSONArray) JSONArray.toJSON(demonstrationPointBuildDetain);
        returnJson.put("demonstrationPointBuildDetainList", demonstrationPointBuildDetainArray);
        returnData.setReturnData(returnJson);
        return returnData;
    }
}
